﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TimeCompare
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        public delegate void Job();
        Job praca;
        public void ShowYes()
        {
            MessageBox.Show("Yes");
        }
        public void ShowNo()
        {
            MessageBox.Show("No");
        }
        DateTime Now;
        DateTime Later;
        
        private void button1_Click(object sender, EventArgs e)
        {
            Later = DateTime.Now.AddSeconds((double)numericUpDown1.Value);
            MessageBox.Show(Later.ToShortDateString() + " " + Later.ToLongTimeString());
            praca = new Job(ShowYes);
            timer1.Enabled = true;
        }


        private void timer1_Tick(object sender, EventArgs e)
        {
            if (DateTime.Now > Later)
            {
                timer1.Enabled = false;
                praca();
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Now = DateTime.Now;
            Later = DateTime.Today.AddSeconds((double)numericUpDown1.Value);
            praca = new Job(ShowNo);
            timer1.Enabled = true;
        }
    }
}
